-- Create table
create table TM_DRAWINGSBORROW
(
  id                    VARCHAR2(600) not null,
  drawingsborrowname    VARCHAR2(600),
  drawingsborrownumber  VARCHAR2(600),
  drawingsborrowversion VARCHAR2(600),
  borrowdate            VARCHAR2(600),
  borrowuser            VARCHAR2(600),
  borrowstate           VARCHAR2(600),
  borrowrejectopinion   VARCHAR2(600),
  borrowbegindate       VARCHAR2(600),
  borrowenddate         VARCHAR2(600),
  createuser            VARCHAR2(600),
  createdate            VARCHAR2(600),
  attr1                 VARCHAR2(600),
  attr2                 VARCHAR2(600),
  attr3                 VARCHAR2(600),
  attr4                 VARCHAR2(600),
  attr5                 VARCHAR2(600),
  attr6                 VARCHAR2(600),
  attr7                 VARCHAR2(4000),
  attr8                 VARCHAR2(4000),
  attr9                 DATE,
  attr10                DATE
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 24K
    next 24K
    minextents 1
    maxextents unlimited
  );
-- Add comments to the columns 
comment on column TM_DRAWINGSBORROW.id
  is 'id';
comment on column TM_DRAWINGSBORROW.drawingsborrowname
  is '借阅文档名称';
comment on column TM_DRAWINGSBORROW.drawingsborrownumber
  is '借阅文档编号';
comment on column TM_DRAWINGSBORROW.drawingsborrowversion
  is '借阅文档版本';
comment on column TM_DRAWINGSBORROW.borrowdate
  is '借阅天数';
comment on column TM_DRAWINGSBORROW.borrowuser
  is '借阅人';
comment on column TM_DRAWINGSBORROW.borrowstate
  is '借阅状态';
comment on column TM_DRAWINGSBORROW.borrowrejectopinion
  is '驳回意见';
comment on column TM_DRAWINGSBORROW.borrowbegindate
  is '借阅开始时间';
comment on column TM_DRAWINGSBORROW.borrowenddate
  is '借阅结束时间';
comment on column TM_DRAWINGSBORROW.createuser
  is '创建用户';
comment on column TM_DRAWINGSBORROW.createdate
  is '创建时间';
comment on column TM_DRAWINGSBORROW.attr1
  is '备用1';
comment on column TM_DRAWINGSBORROW.attr2
  is '备用2';
comment on column TM_DRAWINGSBORROW.attr3
  is '备用3';
comment on column TM_DRAWINGSBORROW.attr4
  is '备用4';
comment on column TM_DRAWINGSBORROW.attr5
  is '备用5';
comment on column TM_DRAWINGSBORROW.attr6
  is '备用6';
comment on column TM_DRAWINGSBORROW.attr7
  is '备用7';
comment on column TM_DRAWINGSBORROW.attr8
  is '备用8';
comment on column TM_DRAWINGSBORROW.attr9
  is '备用9';
comment on column TM_DRAWINGSBORROW.attr10
  is '备用10';
-- Create/Recreate primary, unique and foreign key constraints 
alter table TM_DRAWINGSBORROW
  add constraint PK_ID primary key (ID)
  using index 
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255;
  
  ----创建序列
create sequence TM_DRAWINGSBORROW_SEQ
increment by 1 
start with 1
nomaxvalue
nominvalue
nocache;

----创建触发器
create or replace trigger TM_DRAWINGSBORROW
before insert on TM_DRAWINGSBORROW
for each row
begin
select TM_DRAWINGSBORROW_SEQ.nextval into :new.id from dual;
end;
